﻿using PLCSharp.CoreModel.Common;
using Prism.Commands;
using Prism.Mvvm;
using System.Windows.Media;
namespace PLCSharp.CoreModel.UserControls
{
    public class SimpleCellViewModel : BindableBase
    {

        private DelegateCommand<object> _MenuItemCommand;
        public DelegateCommand<object> MenuItemCommand =>
            _MenuItemCommand ??= new DelegateCommand<object>(ExecuteMenuItemCommand);

        void ExecuteMenuItemCommand(object state)
        {
            CellInfo.State = (CellState)state;

        }

        internal void CellChanged(object sender, CellState e)
        {
            Background = CellInfo.State switch
            {
                CellState.无料 => Brushes.Gray,
                CellState.有料 => Brushes.CornflowerBlue,
                CellState.待加工 => Brushes.Khaki,
                CellState.已完成 => Brushes.LimeGreen,
                CellState.已拍照 => Brushes.Gold,
                CellState.OK => Brushes.Lime,
                CellState.NG => Brushes.Tomato,
                _ => Brushes.Black,
            };
        }

        private Brush _Background;
        /// <summary>
        /// Comment
        /// </summary>
        public Brush Background
        {
            get { return _Background; }
            set { SetProperty(ref _Background, value); }
        }
        private CellInfo _CellInfo;
        /// <summary>
        /// Comment
        /// </summary>
        public CellInfo CellInfo
        {
            get { return _CellInfo; }
            set { SetProperty(ref _CellInfo, value); }
        }
    }
}
